home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / edit / thesrc20.zip / the.h < prev    next >
C/C++ Source or Header  |  1995-01-26  |  36KB  |  973 lines

  1. /*
  2.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  3.  * Copyright (C) 1991-1995 Mark Hessling
  4.  *
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License as
  7.  * published by the Free Software Foundation; either version 2 of
  8.  * the License, or any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13.  * General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to:
  17.  *
  18.  *    The Free Software Foundation, Inc.
  19.  *    675 Mass Ave,
  20.  *    Cambridge, MA 02139 USA.
  21.  *
  22.  *
  23.  * If you make modifications to this software that you feel increases
  24.  * it usefulness for the rest of the community, please email the
  25.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  26.  * This software is going to be maintained and enhanced as deemed
  27.  * necessary by the community.
  28.  *
  29.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  30.  * 36 David Road                     Phone: +61 7 849 7731
  31.  * Holland Park                      Fax:   +61 7 875 5314
  32.  * QLD 4121
  33.  * Australia
  34.  */
  35.  
  36. /*
  37. $Id: the.h 2.0 1995/01/26 16:32:09 MH Release MH $
  38. */
  39.  
  40. #include "defines.h"
  41.  
  42. #if defined(USE_NCURSES)
  43. #   include <ncurses.h>
  44. #   define SYSVR32
  45. #else
  46. #   if defined(USE_EXTCURSES)
  47. #      include <cur00.h>
  48. #      define SYSVR32
  49. #      define A_COLOR
  50. #      define COLOR_BLACK        0
  51. #      define COLOR_BLUE        1
  52. #      define COLOR_GREEN        2
  53. #      define COLOR_CYAN        3
  54. #      define COLOR_RED        4
  55. #      define COLOR_MAGENTA        5
  56. #      define COLOR_YELLOW        6
  57. #      define COLOR_WHITE        7
  58.        typedef char bool;
  59. #      define chtype NLSCHAR
  60. #      define COLORS       8
  61. #      define COLOR_PAIRS 64
  62.        extern chtype color_pair[COLOR_PAIRS];
  63. #      define COLOR_PAIR(n) color_pair[n]
  64. #      define wattrset(win,attr) xstandout(win,attr)
  65. #      define attrset(attr) xstandout(stdscr,attr)
  66. #      define nocbreak() nocrmode()
  67. #      define cbreak() crmode()
  68. #      define wnoutrefresh(win) wrefresh(win)
  69. #   else
  70. #      include <curses.h>
  71. #   endif
  72. #endif
  73.  
  74. #ifdef __OS2__
  75. #  undef MSDOS                 /* in case you are using MSC 6.0 for OS/2 */
  76. #  undef SYSV                  /* set in curses.h */
  77. #  undef BSD                   /* set in curses.h */
  78. #  define SYSVR32curses
  79. #  define SYSVR31curses
  80. #  define SYSVR3curses
  81. #  include <stdlib.h>
  82. #  include <memory.h>
  83. #  include <string.h>
  84. #  include <process.h>
  85. #  include <errno.h>
  86. #  include <ctype.h>
  87. #  include <sys\types.h>
  88. #  include <sys\stat.h>
  89. #  define         W_OK          02
  90. #  define         F_OK          00
  91. #  define         R_OK          04
  92. #  define ESLASH '\\'
  93. #  define ESTR_SLASH (CHARTYPE *)"\\"
  94. #  ifdef EMX
  95. #    define OSLASH '\\'
  96. #    define OSTR_SLASH (CHARTYPE *)"\\"
  97. #    define ISLASH '/'
  98. #    define ISTR_SLASH (CHARTYPE *)"/"
  99. #  else
  100. #    define OSLASH '/'
  101. #    define OSTR_SLASH (CHARTYPE *)"/"
  102. #    define ISLASH '\\'
  103. #    define ISTR_SLASH (CHARTYPE *)"\\"
  104. #  endif
  105. #  define CURRENT_DIR (CHARTYPE *)"."
  106. #  define FMODE (0)
  107. #  ifdef MSC
  108. /* the following 2 defines are to make MSC recognise the new names */
  109. /* of the following OS/2 calls */
  110. #    define DosSetDefaultDisk DosSelectDisk
  111. #    define DosQueryCurrentDisk DosQCurDisk
  112. #  endif
  113. /* the following #define is to eliminate need for the getch.c/getch.h */
  114. /* modules in the OS/2 compilation */
  115. #  define my_getch(win)  wgetch(win)
  116. #endif
  117.  
  118. #if defined(__MSDOS__) || defined(MSDOS)
  119. #  define SYSVR32curses
  120. #  define SYSVR31curses
  121. #  define SYSVR3curses
  122. #  undef SYSV                  /* set in curses.h */
  123. #  undef BSD                   /* set in curses.h */
  124. #  include <stdlib.h>
  125. #  include <memory.h>
  126. #  include <string.h>
  127. #  ifdef GO32
  128. #    include <dir.h>
  129. #  else
  130. #    include <process.h>
  131. #    include <direct.h>
  132. #  endif
  133. #  include <errno.h>
  134. #  include <io.h>
  135. #  include <ctype.h>
  136. #  include <sys\types.h>
  137. #  include <sys\stat.h>
  138. #  define         W_OK          02
  139. #  define         F_OK          00
  140. #  define         R_OK          04
  141. #  define ESLASH '\\'
  142. #  define ESTR_SLASH (CHARTYPE *)"\\"
  143. #  ifdef GO32
  144. #    define OSLASH '\\'
  145. #    define OSTR_SLASH (CHARTYPE *)"\\"
  146. #    define ISLASH '/'
  147. #    define ISTR_SLASH (CHARTYPE *)"/"
  148. #  else
  149. #    define OSLASH '/'
  150. #    define OSTR_SLASH (CHARTYPE *)"/"
  151. #    define ISLASH '\\'
  152. #    define ISTR_SLASH (CHARTYPE *)"\\"
  153. #  endif
  154. #  define CURRENT_DIR (CHARTYPE *)"."
  155. #  define FMODE (0)
  156. /*#define FMODE (S_IREAD | S_IWRITE)*/
  157. /* the following #define is to eliminate need for the getch.c/getch.h */
  158. /* modules in the DOS compilation */
  159. #  define my_getch(win)  wgetch(win)
  160. #endif
  161.  
  162. #ifdef SYSVR4
  163. #  undef BSD
  164. #  ifndef SYSV
  165. #    define SYSV
  166. #  endif
  167. #  include <ctype.h>
  168. #  include <unistd.h>
  169. #  define SYSVR4curses
  170. #  define SYSVR32curses
  171. #  define SYSVR31curses
  172. #  define SYSVR3curses
  173. #endif
  174.  
  175. #ifdef SYSVR32
  176. #  undef BSD
  177. #  ifndef SYSV
  178. #    define SYSV
  179. #  endif
  180. #  include <ctype.h>
  181. #  include <unistd.h>
  182. #  define SYSVR32curses
  183. #  define SYSVR31curses
  184. #  define SYSVR3curses
  185. #endif
  186.  
  187. #ifdef SYSVR31
  188. #  undef BSD
  189. #  ifndef SYSV
  190. #    define SYSV
  191. #  endif
  192. #  define SYSVR31curses
  193. #  define SYSVR3curses
  194. #endif
  195.  
  196. #ifdef SYSVR3
  197. #  undef BSD
  198. #  ifndef SYSV
  199. #    define SYSV
  200. #  endif
  201. #  define SYSVR3curses
  202. #endif
  203.  
  204. #ifdef SYSV
  205. #  undef BSD
  206. #  define SYSVcurses
  207. #  if !defined(ATT)
  208. #    include <stdlib.h>
  209. #    include <sys/file.h>
  210. #  endif
  211. #  include <memory.h>
  212. #  include <string.h>
  213. #  include <sys/types.h>
  214. #  include <sys/stat.h>
  215. #  define FMODE (0)
  216. #  define UNIX 1
  217. #endif
  218.  
  219. #ifdef BSD
  220. #  include <stdlib.h>
  221. #  include <memory.h>
  222. #  include <string.h>
  223. #  include <sys/file.h>
  224. #  include <sys/types.h>
  225. #  include <sys/stat.h>
  226. #  define FMODE (0)
  227. #  define chtype short
  228. #  define UNIX 1
  229. #  define BSDcurses 1
  230. #  define NO_KEYPAD 1
  231. #  define NO_BEEP   1
  232. #  define attrset(attr) wattrset(stdscr,attr)
  233. #  ifdef linux
  234. #    include <unistd.h>
  235. #  endif
  236. #endif
  237.  
  238. #ifdef M_XENIX
  239. #  include <ctype.h>
  240. #  include <sys/types.h>
  241. #  include <sys/stat.h>
  242. #  include <memory.h>
  243. #  include <string.h>
  244. #  include <sys/file.h>
  245. #  define         F_OK          00
  246. #  define         W_OK          02
  247. #  define         R_OK          04
  248. #  define touchline(WIN,START,NUM)       touchwin(WIN)
  249. #  define FMODE (0)
  250. #  define UNIX 1
  251. #endif
  252.  
  253. #ifdef MINIX
  254. #  include <string.h>
  255. #  define short int
  256. #  define UNIX 1
  257. #endif
  258.  
  259. #ifdef UNIX
  260. #  define ESLASH '/'
  261. #  define ESTR_SLASH (CHARTYPE *)"/"
  262. #  define OSLASH '\\'
  263. #  define OSTR_SLASH (CHARTYPE *)"\\"
  264. #  define ISLASH ESLASH
  265. #  define ISTR_SLASH ESTR_SLASH
  266. #  define CURRENT_DIR (CHARTYPE *)"."
  267. #endif
  268.  
  269. #ifdef VMS
  270. #  include <string.h>
  271. #  include <file.h>
  272. #  include <types.h>
  273. #  include <stat.h>
  274. #  include <ctype.h>
  275. #  define         W_OK          02
  276. #  define         F_OK          00
  277. #  define         R_OK          04
  278. #  define ISLASH ']'
  279. #  define ISTR_SLASH (CHARTYPE *)"]"
  280. #  define OSLASH ISLASH
  281. #  define OSTR_SLASH ISTR_SLASH
  282. #  define ESLASH ISLASH
  283. #  define ESTR_SLASH ISTR_SLASH
  284. #  define CURRENT_DIR (CHARTYPE *)"[]"
  285. /*#define FMODE (S_IRWXU | S_IRGRP | S_IROTH)*/
  286. #  define FMODE (0)
  287. #  ifdef BSD
  288. #    define chtype short
  289. #    define BSDcurses 1
  290. #  endif
  291. #  define touchline(WIN,START,NUM)       touchwin(WIN)
  292. /* #define isdigit(c)   (_ctype[(c) + 1] & 2)
  293. #  define islower(c)   (_ctype[(c) + 1] & 8)
  294. #  define isupper(c)   (_ctype[(c) + 1] & 4)*/
  295. #  define NO_KEYPAD 1
  296. #endif
  297. /*---------------------------------------------------------------------*/
  298. /* End of OS-specific defines                                          */
  299. /*---------------------------------------------------------------------*/
  300. #if !defined(SYSVR31curses) || defined(USE_EXTCURSES)
  301. #   define NO_CURS_SET
  302. #endif
  303.  
  304. #if !defined(A_COLOR)
  305. #   define COLOR_BLACK        0
  306. #   define COLOR_BLUE        0
  307. #   define COLOR_GREEN        0
  308. #   define COLOR_CYAN        0
  309. #   define COLOR_RED        0
  310. #   define COLOR_MAGENTA        0
  311. #   define COLOR_YELLOW        0
  312. #   define COLOR_WHITE        0
  313. #endif
  314.  
  315. #ifndef A_NORMAL
  316. /* Various video attributes */
  317. #ifdef BSD
  318. #define A_STANDOUT      BSD_STANDOUT /* for compatability with BSD curses */
  319. #define A_REVERSE       BSD_STANDOUT /* for compatability with BSD curses */
  320. #define A_UNDERLINE     0
  321. #define A_BLINK         0
  322. #define A_DIM           0
  323. #define A_BOLD          BSD_STANDOUT
  324.  
  325. /* The next two are subject to change so don't depend on them */
  326. #define A_INVIS         0
  327. #define A_PROTECT       0
  328.  
  329. #define A_NORMAL        0
  330. #define A_CHARTEXT      0x007F
  331. #define A_ATTRIBUTES    ~A_CHARTEXT
  332. #define A_ALTCHARSET    0
  333.  
  334. #else
  335.  
  336. #define A_STANDOUT      000000200000L
  337. #define A_UNDERLINE     000000400000L
  338. #define A_REVERSE       000001000000L
  339. #define A_BLINK         000002000000L
  340. #define A_DIM           000004000000L
  341. #define A_BOLD          000010000000L
  342. #define A_ALTCHARSET    000100000000L
  343.  
  344. /* The next two are subject to change so don't depend on them */
  345. #define A_INVIS         000020000000L
  346. #define A_PROTECT       000040000000L
  347.  
  348. #define A_NORMAL        000000000000L
  349. #define A_ATTRIBUTES    037777600000L   /* 0xFFFF0000 */
  350. #define A_CHARTEXT      000000177777L   /* 0x0000FFFF */
  351.  
  352. #endif
  353. #endif
  354.  
  355. #define ATTR2PAIR(fg,bg) (bg|(fg<<3))
  356. #define FOREFROMPAIR(p)  (p>>3)
  357. #define BACKFROMPAIR(p)  (p&0x07)
  358.  
  359. #ifndef max
  360. #define max(a,b)        (((a) > (b)) ? (a) : (b))
  361. #endif
  362.  
  363. #ifndef min
  364. #define min(a,b)        (((a) < (b)) ? (a) : (b))
  365. #endif
  366.  
  367. #ifndef getmaxy
  368. #ifdef VMS
  369. #define getmaxy(win)    ((win)->_max_y)
  370. #else
  371. #define getmaxy(win)    ((win)->_maxy)
  372. #endif
  373. #endif
  374.  
  375. #ifndef getmaxx
  376. #ifdef VMS
  377. #define getmaxx(win)    ((win)->_max_x)
  378. #else
  379. #define getmaxx(win)    ((win)->_maxx)
  380. #endif
  381. #endif
  382.  
  383. #ifndef getmaxyx
  384. #define getmaxyx(win,y,x)  ((y) = getmaxy(win), (x) = getmaxx(win))
  385. #endif
  386.  
  387. #define QUIT          (-127)
  388. #define SKIP          (-126)
  389. #define QUITOK        (-125)
  390. #define RAW_KEY       (128)
  391.  
  392. #define MAX_SCREENS         2              /* maximum number of screens*/
  393. #define VIEW_WINDOWS        5            /* number of windows per view */
  394. #define MAX_INT             32766          /* maximum size for integer */
  395. #define MAX_LONG            2147483001L       /* maximum size for long */
  396. #define WORD_DELIMS         (CHARTYPE *)" \t" /* word delimiter characters */
  397.  
  398. #define TOP_OF_FILE         (CHARTYPE *)"*** Top of File ***"
  399. #define BOTTOM_OF_FILE      (CHARTYPE *)"*** Bottom of File ***"
  400. #define DIRECTION_NONE      0
  401. #define DIRECTION_FORWARD   1
  402. #define DIRECTION_BACKWARD  (-1)
  403.  
  404. #define UNDEFINED_OPERAND (-1)
  405.  
  406. #define WINDOW_MAIN     0
  407. #define WINDOW_PREFIX   1
  408. #define WINDOW_COMMAND  2
  409. #define WINDOW_ARROW    3
  410. #define WINDOW_IDLINE   4
  411. #define WINDOW_FOOTING  5
  412. #define WINDOW_ERROR    6
  413. #define WINDOW_DIVIDER  7
  414. #define WINDOW_RESERVED 8
  415.  
  416. #define PREFIX_WIDTH    6
  417.  
  418. #define CURRENT_VIEW              (vd_current)
  419. #define PREVIOUS_VIEW             (vd_current->prev)
  420. #define NEXT_VIEW                 (vd_current->next)
  421.  
  422. #define CURRENT_FILE              (vd_current->file_for_view)
  423.  
  424. #define CURRENT_WINDOW            (screen[current_screen].win[vd_current->current_window])
  425. #define PREVIOUS_WINDOW           (screen[current_screen].win[vd_current->previous_window])
  426. #define CURRENT_WINDOW_MAIN       (screen[current_screen].win[WINDOW_MAIN])
  427. #define CURRENT_WINDOW_PREFIX     (screen[current_screen].win[WINDOW_PREFIX])
  428. #define CURRENT_WINDOW_COMMAND    (screen[current_screen].win[WINDOW_COMMAND])
  429. #define CURRENT_WINDOW_ARROW      (screen[current_screen].win[WINDOW_ARROW])
  430. #define CURRENT_WINDOW_IDLINE     (screen[current_screen].win[WINDOW_IDLINE])
  431.  
  432. #define MARK_VIEW (vd_mark)
  433. #define MARK_FILE (vd_mark->file_for_view)
  434.  
  435. #define CURRENT_SCREEN (screen[current_screen])
  436. #define OTHER_SCREEN (screen[(current_screen == 0) ? 1 : 0])
  437.  
  438. /*------------------------ block move command types ------------------*/
  439. #define COMMAND_COPY             1
  440. #define COMMAND_DELETE           2
  441. #define COMMAND_DUPLICATE        3
  442. #define COMMAND_MOVE_COPY_SAME   4
  443. #define COMMAND_MOVE_COPY_DIFF   5
  444. #define COMMAND_MOVE_DELETE_SAME 6
  445. #define COMMAND_MOVE_DELETE_DIFF 7
  446. /*------------------------ block move source types -------------------*/
  447. #define SOURCE_UNKNOWN      0
  448. #define SOURCE_COMMAND      1
  449. #define SOURCE_PREFIX       2
  450. #define SOURCE_BLOCK        3
  451. #define SOURCE_BLOCK_RESET  4
  452. /*---------------------- return code constants ------------------------*/
  453. #define     RC_OK               0
  454. #define     RC_NOT_COMMAND     -1
  455. #define     RC_INVALID_ENVIRON -3
  456. #define     RC_TOF_EOF_REACHED  1
  457. #define     RC_TARGET_NOT_FOUND 2
  458. #define     RC_TRUNCATED        3
  459. #define     RC_NO_LINES_CHANGED 4
  460. #define     RC_INVALID_OPERAND  5
  461. #define     RC_COMMAND_NO_FILES 6
  462. #define     RC_FILE_CHANGED    12
  463. #define     RC_ACCESS_DENIED   12
  464. #define     RC_DISK_FULL       13
  465. #define     RC_BAD_FILEID      20
  466. #define     RC_BAD_DRIVE       24
  467. #define     RC_FILE_NOT_FOUND  28
  468. #define     RC_OUT_OF_MEMORY   94
  469. #define     RC_SYSTEM_ERROR    99
  470. /*---------------------- global parameters ----------------------------*/
  471. #define EOLOUT_LF                0
  472. #define EOLOUT_CRLF              1
  473. /*---------------------- extract return codes -------------------------*/
  474. #define EXTRACT_ARG_ERROR        (-2)
  475. #define EXTRACT_VARIABLES_SET    (-1)
  476. /*---------------------- attribute defines ----------------------------*/
  477. #define ATTR_FILEAREA   0
  478. #define ATTR_CURLINE    1
  479. #define ATTR_BLOCK      2
  480. #define ATTR_CBLOCK     3
  481. #define ATTR_CMDLINE    4
  482. #define ATTR_IDLINE     5
  483. #define ATTR_MSGLINE    6
  484. #define ATTR_ARROW      7
  485. #define ATTR_PREFIX     8
  486. #define ATTR_PENDING    9
  487. #define ATTR_SCALE     10
  488. #define ATTR_TOFEOF    11
  489. #define ATTR_CTOFEOF   12
  490. #define ATTR_TABLINE   13
  491. #define ATTR_SHADOW    14
  492. #define ATTR_STATAREA  15
  493. #define ATTR_DIVIDER   16
  494. #define ATTR_RESERVED  17
  495. #define ATTR_MAX       18
  496. /*---------------------- display line types --------------------------*/
  497. #define LINE_LINE                 0
  498. #define LINE_TABLINE              1
  499. #define LINE_SCALE                2
  500. #define LINE_SHADOW               4
  501. #define LINE_TOF_EOF              8
  502. #define LINE_RESERVED            16
  503. #define LINE_OUT_OF_BOUNDS_ABOVE 32
  504. #define LINE_OUT_OF_BOUNDS_BELOW 64
  505. #define LINE_HEXSHOW            128
  506. /*--------------------------- target types ---------------------------*/
  507. #define TARGET_ERR          (-1)
  508. #define TARGET_UNFOUND        0x000
  509. #define TARGET_ABSOLUTE       0x001
  510. #define TARGET_RELATIVE       0x002
  511. #define TARGET_STRING         0x004
  512. #define TARGET_POINT          0x008
  513. #define TARGET_BLANK          0x010
  514. #define TARGET_NORMAL         TARGET_ABSOLUTE|TARGET_RELATIVE|TARGET_STRING|TARGET_POINT|TARGET_BLANK
  515. #define TARGET_ALL            0x020
  516. #define TARGET_BLOCK          0x040
  517. #define TARGET_BLOCK_ANY      0x080
  518. #define TARGET_BLOCK_CURRENT  0x100
  519. #define TARGET_SPARE          0x200
  520. /*--------------------------- compatiblility modes -------------------*/
  521. #define COMPAT_THE            0
  522. #define COMPAT_XEDIT          1
  523. #define COMPAT_KEDIT          2
  524. /*--------------------------- cursor commands ------------------------*/
  525. #define CURSOR_START          (-1)
  526. #define CURSOR_ERROR          (-2)
  527. #define CURSOR_HOME           0
  528. #define CURSOR_HOME_LAST      1
  529. #define CURSOR_SCREEN         2
  530. #define CURSOR_SCREEN_UP      3
  531. #define CURSOR_SCREEN_DOWN    4
  532. #define CURSOR_SCREEN_LEFT    5
  533. #define CURSOR_SCREEN_RIGHT   6
  534. #define CURSOR_ESCREEN        7
  535. #define CURSOR_ESCREEN_UP     8
  536. #define CURSOR_ESCREEN_DOWN   9
  537. #define CURSOR_ESCREEN_LEFT   10
  538. #define CURSOR_ESCREEN_RIGHT  11
  539. #define CURSOR_COLUMN         12
  540. #define CURSOR_FILE           13
  541. #define CURSOR_CMDLINE        14
  542. #define CURSOR_KEDIT          15
  543. /*--------------------------- defines for tabbing to fields ----------*/
  544. #define WHERE_WINDOW_MASK             0x0000FF00L
  545. #define WHERE_WINDOW_MAIN             0x00000100L
  546. #define WHERE_WINDOW_PREFIX_LEFT      0x00000200L
  547. #define WHERE_WINDOW_PREFIX_RIGHT     0x00000400L
  548. #define WHERE_WINDOW_CMDLINE_TOP      0x00000800L
  549. #define WHERE_WINDOW_CMDLINE_BOTTOM   0x00001000L
  550. #define WHERE_ROW_MASK                0x000000FFL
  551. #define WHERE_SCREEN_MASK             0x000F0000L
  552. #define WHERE_SCREEN_FIRST            0x00010000L
  553. #define WHERE_SCREEN_LAST             0x00020000L
  554. #define WHERE_SCREEN_ONLY             0x00040000L
  555.  
  556. struct pending_prefix_command
  557.  {
  558.   struct pending_prefix_command *next;
  559.   struct pending_prefix_command *prev;
  560.   CHARTYPE ppc_command[PREFIX_WIDTH+1];              /* prefix command */
  561.   LINETYPE ppc_line_number;                     /* line number in file */
  562.   LINETYPE ppc_cmd_param;                  /* prefix command parameter */
  563.   short ppc_cmd_idx;                           /* prefix command index */
  564.   bool ppc_block_command;                     /* is it a BLOCK command */
  565.  };
  566. typedef struct pending_prefix_command PPC;
  567.  
  568. struct line
  569.  {
  570.   struct line *prev;                       /* pointer to previous line */
  571.   struct line *next;                           /* pointer to next line */
  572.   CHARTYPE *name;            /* pointer to name of line (for SET POINT)*/
  573.   CHARTYPE *line;                       /* pointer to contents of line */
  574.   LENGTHTYPE length;                   /* number of characters in line */
  575.   PPC *pre;
  576.   SELECTTYPE select;                     /* select level for each line */
  577.   SELECTTYPE save_select;          /* saved select level (used by ALL) */
  578.  };
  579. typedef struct line LINE;
  580.  
  581. struct colour_attr
  582.  {
  583.   int pair;                                  /* pair number for colour */
  584.   chtype mod;                                       /* colour modifier */
  585.   chtype mono;                                      /* mono attributes */
  586.  };
  587. typedef struct colour_attr COLOUR_ATTR;
  588.  
  589. struct reserved
  590.  {
  591.   struct reserved *prev;          /* pointer to previous reserved line */
  592.   struct reserved *next;              /* pointer to next reserved line */
  593.   CHARTYPE *line;                       /* pointer to contents of line */
  594.   CHARTYPE *spec;                        /* row position specification */
  595.   short length;                             /* length of reserved line */
  596.   short base;                                              /* row base */
  597.   short off;                                   /* row offset from base */
  598.   COLOUR_ATTR *attr;                              /* colour attributes */
  599.  };
  600. typedef struct reserved RESERVED;
  601.  
  602. struct prefix_commands
  603.  {
  604.   CHARTYPE *cmd;                                     /* prefix command */
  605.   LENGTHTYPE cmd_len;                      /* length of prefix command */
  606.   bool action_prefix;              /* is command an action or a target */
  607.   bool multiples_allowed;                     /* are multiples allowed */
  608.   bool full_target_allowed;            /* full target multiple allowed */
  609.   bool block_prefix_command;             /* is command a block command */
  610.   bool target_required;                 /* does command require target */
  611.   bool valid_on_tof;         /* is command allowed on Top of File line */
  612.   bool valid_on_bof;      /* is command allowed on Bottom of File line */
  613.   bool valid_in_readonly;    /* TRUE if command valid in readonly mode */
  614. #ifdef PROTO
  615.  short (*function)(PPC *,short,LINETYPE);
  616. #else
  617.  short (*function)();
  618. #endif
  619.   LINETYPE default_target;/* number of lines to process if not specified */
  620.   bool ignore_scope;/* TRUE if scope to be ignored when finding target */
  621.   bool use_last_not_in_scope;/* TRUE if starting at end of shadow lines*/
  622.  };
  623. typedef struct prefix_commands PREFIX_COMMAND;
  624.  
  625. typedef struct
  626.  {
  627.   short backup;           /* indicates type of backup file to be saved */
  628.   CHARTYPE autosave;        /* number of alterations before autosaving */
  629.   CHARTYPE eolout;     /* indicates how lines are terminated on output */
  630.   ROWTYPE status_row;         /* row on which status line is displayed */
  631.   bool tabsout_on;      /* indicates if tabs to replace spaces on file */
  632.   CHARTYPE tabsout_num;                 /* length of tab stops on file */
  633.   bool pseudo_file;   /* indicates if file is a "pseudo" file and if so, what sort */
  634.   unsigned short autosave_alt;  /* number of alterations since last autosave */
  635.   unsigned short save_alt;    /* number of alterations since last save */
  636.   FILE *fp;                               /* file handle for this file */
  637.   CHARTYPE *fname;                                        /* file name */
  638.   CHARTYPE *fpath;                                        /* file path */
  639.   unsigned short fmode;                           /* file mode of file */
  640.   LINE *first_line;                           /* pointer to first line */
  641.   LINE *last_line;                             /* pointer to last line */
  642.   RESERVED *first_reserved;          /* pointer to first reserved line */
  643.   LINETYPE  number_lines;            /* number of actual lines in file */
  644.   LINETYPE  max_line_length;            /* Maximum line length in file */
  645.   CHARTYPE file_views;              /* number of views of current file */
  646.   PPC *first_ppc;                      /* first pending prefix command */
  647.   PPC *last_ppc;                        /* last pending prefix command */
  648.   COLOUR_ATTR *attr;                              /* colour attributes */
  649.  } FILE_DETAILS;
  650.  
  651. struct view_details
  652.  {
  653.   struct view_details *prev;               /* pointer to previous view */
  654.   struct view_details *next;                   /* pointer to next view */
  655.   bool arbchar_status;                   /* indicates if arbchar is on */
  656.   CHARTYPE arbchar_single;         /* single arbitrary character value */
  657.   CHARTYPE arbchar_multiple;     /* multiple arbitrary character value */
  658.   ROWTYPE cmd_line;                        /* position of command line */
  659.   bool id_line;                            /* TRUE if IDLINE displayed */
  660.   CHARTYPE tab_base;   /* base position on which tab line is displayed */
  661.   short  tab_off;  /* offset from base position on which tab line is displayed */
  662.   bool tab_on;             /* indicates if tab line is to be displayed */
  663.   CHARTYPE scale_base;/* base position on which scale row is displayed */
  664.   short  scale_off; /* offset from base position on which scale row is displayed */
  665.   bool scale_on;                    /* indicates if scale is displayed */
  666.   ROWTYPE current_row;                     /* row which is current row */
  667.   CHARTYPE current_base;/* indicates relative position of current line */
  668.   short current_off;       /* offset from current_base for current_row */
  669.   CHARTYPE prefix;       /* indicates if and where prefix is displayed */
  670.   bool number;   /* indicates if numbers in prefix are to be displayed */
  671.   bool msgmode_status;    /* indicates if messages are to be displayed */
  672.   CHARTYPE msgline_base;     /* indicates relative position of msgline */
  673.   short msgline_off;           /* offset from msgline_base for msgline */
  674.   ROWTYPE msgline_rows;                   /* number of rows in msgline */
  675.   bool imp_macro;       /* indicates if implied macro processing is on */
  676.   bool imp_os;             /* indicates if implied os processing is on */
  677.   CHARTYPE case_enter;               /* indicates case of data entered */
  678.   CHARTYPE case_locate;              /* indicates case of data located */
  679.   CHARTYPE case_change;              /* indicates case of data changed */
  680.   CHARTYPE case_sort;       /* indicates case significance for sorting */
  681.   SELECTTYPE display_low;                /* low range of display level */
  682.   SELECTTYPE display_high;              /* high range of display level */
  683.   bool scope_all; /* indicates if commands act on All lines or only those Displayed */
  684.   bool shadow;        /* indicates if shadow lines are to be displayed */
  685.   bool stay;                               /* indicates status of STAY */
  686.   bool newline_aligned; /* TRUE if adding a new line results in cursor appearing under 1st non-blank of previous line */
  687.   bool hex;       /* TRUE if hex conversion is done on string operands */
  688.   LENGTHTYPE margin_left;                /* left margin column 1 based */
  689.   LENGTHTYPE margin_right;              /* right margin column 1 based */
  690.   LENGTHTYPE margin_indent;                   /* paragraph indentation */
  691.   bool margin_indent_offset; /* TRUE if paragraph indentation is an offset from left column */
  692.   LENGTHTYPE verify_col;                /* left col for current verify */
  693.   LENGTHTYPE verify_start;                   /* col of start of verify */
  694.   LENGTHTYPE verify_end;                       /* col of end of verify */
  695.   bool hexshow_on;                                /* status of hexshow */
  696.   CHARTYPE hexshow_base;  /* base position for starting row of hexshow */
  697.   short hexshow_off;           /* offset from base of start of hexshow */
  698.   bool wordwrap;                                   /* wordwrap setting */
  699.   bool position_status;     /* TRUE if LINE/COL is displayed on IDLINE */
  700.   LENGTHTYPE zone_start;                       /* col of start of zone */
  701.   LENGTHTYPE zone_end;                           /* col of end of zone */
  702.   bool linend_status; /* indicates if multiple commands allowed on command line */
  703.   CHARTYPE linend_value;                /* specifies command delimiter */
  704.   LINETYPE current_line;      /* line in file displayed on current row */
  705.   LENGTHTYPE current_column;   /* column in line of last column target */
  706.   COLTYPE numtabs;                      /* number of tab stops defined */
  707.   LENGTHTYPE tabs[MAX_NUMTABS];      /* tab settings for each tab stop */
  708.   short y[VIEW_WINDOWS];               /* y coordinate for each window */
  709.   short x[VIEW_WINDOWS];               /* x coordinate for each window */
  710.   LINETYPE focus_line;                 /* line in file where cursor is */
  711.   short mark_type;                             /* type of marked block */
  712.   LINETYPE mark_start_line;                 /* first line to be marked */
  713.   LINETYPE mark_end_line;                    /* last line to be marked */
  714.   bool marked_line;                             /* TRUE if line marked */
  715.   LENGTHTYPE mark_start_col;                    /* first column marked */
  716.   LENGTHTYPE mark_end_col;                       /* last column marked */
  717.   bool marked_col;                            /* TRUE if column marked */
  718.   CHARTYPE current_window;        /* current window for current screen */
  719.   CHARTYPE previous_window;      /* previous window for current screen */
  720.   FILE_DETAILS *file_for_view;            /* pointer to file structure */
  721.  };
  722. typedef struct view_details VIEW_DETAILS;
  723.  
  724. /* structure for each line to be displayed */
  725. struct show_line
  726.  {
  727.   CHARTYPE *contents;                   /* pointer to contents of line */
  728.   LENGTHTYPE length;                   /* number of characters in line */
  729.   chtype normal_colour;                      /* normal colour for line */
  730.   chtype other_colour;                        /* other colour for line */
  731.   LENGTHTYPE other_start_col; /* start column of other colour from col 0 */
  732.   LENGTHTYPE other_end_col;   /* end column of other colour from col 0 */
  733.   LINETYPE number_lines_excluded;          /* number of lines excluded */
  734.   LINETYPE line_number;                     /* line number within file */
  735.   LINE *current;                            /* pointer to current line */
  736.   chtype prefix_colour;                            /* colour of prefix */
  737.   CHARTYPE prefix[PREFIX_WIDTH+1];          /* contents of prefix area */
  738.   short line_type;                                     /* type of line */
  739.   bool full_length;                 /* TRUE if all columns to be drawn */
  740.   bool prefix_enterable;            /* TRUE if prefix can be tabbed to */
  741.   bool main_enterable;            /* TRUE if filearea can be tabbed to */
  742.  };
  743. typedef struct show_line SHOW_LINE;
  744.  
  745. /* structure for each screen */
  746. typedef struct
  747.  {
  748.   ROWTYPE screen_start_row;                     /* start row of screen */
  749.   COLTYPE screen_start_col;                     /* start col of screen */
  750.   ROWTYPE screen_rows;                                /* physical rows */
  751.   COLTYPE screen_cols;                                /* physical cols */
  752.   ROWTYPE rows[VIEW_WINDOWS];                        /* rows in window */
  753.   COLTYPE cols[VIEW_WINDOWS];                        /* cols in window */
  754.   ROWTYPE start_row[VIEW_WINDOWS];              /* start row of window */
  755.   COLTYPE start_col[VIEW_WINDOWS];              /* start col of window */
  756.   WINDOW *win[VIEW_WINDOWS];  /* curses windows for the screen display */
  757.   VIEW_DETAILS *screen_view;    /* view being displayed in this screen */
  758.   SHOW_LINE *sl;       /* pointer to SHOW_DETAILS structure for screen */
  759.  } SCREEN_DETAILS;
  760.  
  761. #define STATUS_ROW         (screen_rows-1)
  762. #define COMMAND_ROW        (screen_rows-2)
  763. #define ERROR_ROW          1
  764. #define TAB_ROW            6
  765. #define TAB_ON             NO
  766. #define SCALE_ROW          6
  767. #define SCALE_ON           NO
  768. #define CURSOR_ROW         COMMAND_ROW
  769. #define CURSOR_COL         5
  770. #define CURRENT_ROW_POS    0
  771. #define CURRENT_ROW        0
  772. #define ZONE_START         1
  773. #define ZONE_END           MAX_INT
  774.  
  775. /* defines for base value for relative row positions */
  776. #define POSITION_TOP       0
  777. #define POSITION_MIDDLE    1
  778. #define POSITION_BOTTOM    2
  779.  
  780. /* defines for pseudo file types */
  781. #define PSEUDO_REAL        0
  782. #define PSEUDO_DIR         1
  783. #define PSEUDO_REXX        2
  784.  
  785. /* defines for prefix settings */
  786. #define PREFIX_OFF           0x00
  787. #define PREFIX_ON            0x10
  788. #define PREFIX_NULLS         0x20
  789. #define PREFIX_LEFT          0x01
  790. #define PREFIX_RIGHT         0x02
  791. #define PREFIX_LOCATION_MASK 0x0F
  792. #define PREFIX_STATUS_MASK   0xF0
  793.  
  794. /* defines for query types */
  795. #define QUERY_NONE         0
  796. #define QUERY_QUERY        1
  797. #define QUERY_STATUS       2
  798. #define QUERY_EXTRACT      4
  799. #define QUERY_FUNCTION     8
  800. #define QUERY_MODIFY      16
  801. #define QUERY_READV       32
  802.  
  803. /* defines for case settings */
  804. #define CASE_MIXED         (CHARTYPE)'M'
  805. #define CASE_UPPER         (CHARTYPE)'U'
  806. #define CASE_LOWER         (CHARTYPE)'L'
  807. #define CASE_IGNORE        (CHARTYPE)'I'
  808. #define CASE_RESPECT       (CHARTYPE)'R'
  809.  
  810. /* type of marked blocks */
  811. #define M_LINE             1
  812. #define M_BOX              2
  813. #define M_STREAM           3
  814. #define M_COLUMN           4
  815. #define M_WORD             5
  816.  
  817. /* defines for temporary space allocation */
  818. #define TEMP_PARAM         1
  819. #define TEMP_MACRO         2
  820. #define TEMP_TMP_CMD       3
  821. #define TEMP_TEMP_CMD      4
  822.  
  823. /* defines for [SET] BACKUP */
  824. #define BACKUP_OFF         1
  825. #define BACKUP_TEMP        2
  826. #define BACKUP_KEEP        3
  827. #define BACKUP_ON          BACKUP_KEEP
  828.  
  829. /* box opertaions */
  830. #define BOX_C           1
  831. #define BOX_M           2
  832. #define BOX_D           3
  833. #define BOX_F           4
  834.  
  835. #ifndef FILE_NORMAL
  836. #define FILE_NORMAL        0
  837. #endif
  838.  
  839. #ifndef FILE_READONLY
  840. #define FILE_READONLY      1
  841. #endif
  842.  
  843. #ifndef FILE_NEW
  844. #define FILE_NEW          99
  845. #endif
  846.  
  847. #define COMMAND_ONLY_TRUE    TRUE
  848. #define COMMAND_ONLY_FALSE   FALSE
  849.  
  850. #define ADDCHAR            0
  851. #define INSCHAR            1
  852.  
  853. #ifndef getbegyx
  854. #define getbegyx(win,y,x)       (y = (win)->_begy, x = (win)->_begx)
  855. #endif
  856.  
  857. #define HIT_ANY_KEY "Hit any key to continue..."
  858.  
  859. /*---------------------- useful macros --------------------------------*/
  860. #define     TOF(line)           ((line == 0L) ? TRUE : FALSE)
  861. #define     BOF(line)           ((line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  862. #define     VIEW_TOF(view,line) ((line == 0L) ? TRUE : FALSE)
  863. #define     VIEW_BOF(view,line) ((line == view->file_for_view->number_lines+1L) ? TRUE : FALSE)
  864. #define     CURRENT_TOF         ((CURRENT_VIEW->current_line == 0L) ? TRUE : FALSE)
  865. #define     CURRENT_BOF         ((CURRENT_VIEW->current_line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  866. #define     FOCUS_TOF           ((CURRENT_VIEW->focus_line == 0L) ? TRUE : FALSE)
  867. #define     FOCUS_BOF           ((CURRENT_VIEW->focus_line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  868. #define     IN_VIEW(view,line)   ((line >= (view->current_line - (LINETYPE)view->current_row)) && (line <= (view->current_line + ((LINETYPE)CURRENT_SCREEN.rows - (LINETYPE)view->current_row))))
  869. /*---------------------- system specific redefines --------------------*/
  870. #ifdef VAX
  871. #define     wattrset     wsetattr
  872. #define     A_REVERSE    _REVERSE
  873. #define     A_BOLD       _BOLD
  874. #endif
  875.  
  876. extern VIEW_DETAILS *vd_current;
  877. extern CHARTYPE current_screen;
  878. extern SCREEN_DETAILS screen[MAX_SCREENS];
  879.  
  880. #ifdef MAIN
  881. LENGTHTYPE max_line_length=MAX_LENGTH_OF_LINE;
  882. #else
  883. extern LENGTHTYPE max_line_length;
  884. #endif
  885.  
  886. #define PARACOL (CURRENT_VIEW->margin_indent_offset ? CURRENT_VIEW->margin_left + CURRENT_VIEW->margin_indent : CURRENT_VIEW->margin_indent)
  887.  
  888. /* structure for passing box parameters */
  889. struct _boxp
  890.  {
  891.   short action;
  892.   LENGTHTYPE src_start_col;
  893.   LENGTHTYPE dst_start_col;
  894.   LENGTHTYPE num_cols;
  895.   LINETYPE src_start_line;
  896.   LINETYPE dst_start_line;
  897.   LINETYPE num_lines;
  898.   LINE *curr_src;
  899.   LINE *curr_dst;
  900.  };
  901. typedef struct _boxp BOXP;
  902.  
  903. /* structure for passing queryable values parameters */
  904. struct query_values
  905.  {
  906.   CHARTYPE *value;                                    /* value of item */
  907.   short len;               /* length of string representation of value */
  908.  };
  909. typedef struct query_values VALUE;
  910.  
  911. /* structure for function key redefinition */
  912. struct defines
  913. {
  914.  struct defines *prev;
  915.  struct defines *next;
  916.  int def_funkey;
  917.  short def_command;
  918.  CHARTYPE *def_params;
  919. };
  920. typedef struct defines DEFINE;
  921.  
  922. /* structure for repeating targets */
  923. struct rtarget
  924.  {
  925.   CHARTYPE *string;                               /* pointer to target */
  926.   unsigned short length;                           /* length of target */
  927.   CHARTYPE boolean;                                /* boolean operator */
  928.   bool not;                                      /* TRUE if NOT target */
  929.   LINETYPE numeric_target;                     /* numeric target value */
  930.   short  target_type;                                /* type of target */
  931.   bool negative;                         /* TRUE if direction backward */
  932.  };
  933. typedef struct rtarget RTARGET;
  934.  
  935. /* structure for targets */
  936. struct target
  937.  {
  938.   CHARTYPE *string;                      /* pointer to original target */
  939.   LINETYPE num_lines;                     /* number of lines to target */
  940.   LINETYPE true_line;                     /* line number to start with */
  941.   RTARGET *rt;                         /* pointer to repeating targets */
  942.   short num_targets;                        /* number of targets found */
  943.   short spare;             /* index to which repeating target is spare */
  944.   bool ignore_scope;/* TRUE if scope to be ignored when finding target */
  945.  };
  946. typedef struct target TARGET;
  947.  
  948. #if defined(MAIN)
  949. #  ifdef MSWIN
  950. void far * (*the_malloc)(unsigned long);             /* ptr to some malloc(size) */
  951. void far * (*the_calloc)();                          /* ptr to some ecalloc(num,size)*/
  952. void  (*the_free)();                            /* ptr to some free(ptr) */
  953. void far * (*the_realloc)(void far *,unsigned long); /* ptr to some realloc(ptr,size) */
  954. #  else
  955. void* (*the_malloc)();  /* ptr to some malloc(size) */
  956. void* (*the_calloc)();  /* ptr to some ecalloc(num,size)*/
  957. void  (*the_free)();    /* ptr to some free(ptr) */
  958. void* (*the_realloc)(); /* ptr to some realloc(ptr,size) */
  959. #  endif
  960. #else
  961. #  ifdef MSWIN
  962. extern void far * (*the_malloc)(unsigned long);
  963. extern void far * (*the_calloc)();
  964. extern void  (*the_free)();
  965. extern void far * (*the_realloc)(void far *,unsigned long);
  966. #  else
  967. extern void* (*the_malloc)();
  968. extern void* (*the_calloc)();
  969. extern void  (*the_free)();
  970. extern void* (*the_realloc)();
  971. #  endif
  972. #endif
  973.